package tuding.android.bigplanettracks.maps.ui;

import tuding.android.bigplanettracks.R;
import tuding.android.bigplanettracks.maps.tuding.ActionBase;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;


public class AddPhotosDialog {
    public final static int  GALLERY=40;//Source is gallery
    public final static int  CAMERA=41;//source is camera

	public static void show(final Context context, final ActionBase geoBookmark,
			final OnDialogClickListener onClickListener) {
	    
	    final Dialog dialog = new Dialog(context);
        dialog.setContentView(R.layout.picselect);
        dialog.setTitle("Choose a source");
        dialog.setCancelable(true);
        View camera = dialog.findViewById(R.id.launch_camera);
        camera.setOnClickListener(new OnClickListener(){
            @Override
            //choose to take photos
            public void onClick(View v) {
                try {
                    Intent i = new Intent("android.media.action.IMAGE_CAPTURE");
                    ((Activity) context).startActivityForResult(i, CAMERA);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                dialog.dismiss();
               
            }});
        View gallery = dialog.findViewById(R.id.launch_photo_gallery);
        gallery.setOnClickListener(new OnClickListener(){
            @Override
            //choose to take photos
            public void onClick(View v) {
                Intent intent = new Intent();
                intent = new Intent(
                        Intent.ACTION_PICK,
                        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                ((Activity) context).startActivityForResult(Intent.createChooser(intent, "Gallery"),
                        GALLERY);
                dialog.dismiss();
            }});
        dialog.show();
	}
}
